package com.hxzy.core.tags;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.jsp.JspException;

import com.hxzy.core.cache.DictCache;
import com.hxzy.core.tags.base.AbstractTag;
import com.hxzy.core.tags.helper.TagWriter;

/**
 * 根据指定的“代码集”与“值”输出对应内容
 * @author Abdi
 * @description 
 * @created Oct 25, 2013 3:42:47 PM
 */
@SuppressWarnings("unchecked")
public class OutTag extends AbstractTag{
	/**
	 * 
	 */
	private static final long serialVersionUID = -2738159467160584117L;
	private String value;
	private String valueset;
	private String params;
	
	@Override
	protected int writeTagContent(TagWriter tagWriter) throws JspException {
		Map queryMap = new HashMap();
		String params = getDisplayString(evaluate("params", getParams()));
		String name = null;
		if(null == name){
			name = getValue();
		}
		DictCache cache = DictCache.getInstance();
		if(null != cache){
			name = cache.getCodeName(getDisplayString(evaluate(
					"valueset", getValueset())), getDisplayString(evaluate(
					"value", getValue())), queryMap);
		}else{
			name = getValue();
		}
		tagWriter.onlyContent(name);
		return SKIP_BODY;
	}
	
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getValueset() {
		return valueset;
	}
	public void setValueset(String valueset) {
		this.valueset = valueset;
	}

	public String getParams() {
		return params;
	}

	public void setParams(String params) {
		this.params = params;
	}
}
